home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / pacman.c < prev    next >
C/C++ Source or Header  |  1999-12-07  |  1KB  |  54 lines

  1. /***************************************************************************
  2.  
  3.   machine.c
  4.  
  5.   Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
  6.   I/O ports)
  7.  
  8. ***************************************************************************/
  9.  
  10. #include "driver.h"
  11.  
  12. static int speedcheat = 0;    /* a well known hack allows to make Pac Man run at four times */
  13.                     /* his usual speed. When we start the emulation, we check if the */
  14.                     /* hack can be applied, and set this flag accordingly. */
  15.  
  16.  
  17. void pacman_init_machine(void)
  18. {
  19.     unsigned char *RAM = memory_region(REGION_CPU1);
  20.  
  21.  
  22.     /* check if the loaded set of ROMs allows the Pac Man speed hack */
  23.     if ((RAM[0x180b] == 0xbe && RAM[0x1ffd] == 0x00) ||
  24.             (RAM[0x180b] == 0x01 && RAM[0x1ffd] == 0xbd))
  25.         speedcheat = 1;
  26.     else
  27.         speedcheat = 0;
  28. }
  29.  
  30. int pacman_interrupt(void)
  31. {
  32.     unsigned char *RAM = memory_region(REGION_CPU1);
  33.  
  34.  
  35.     /* speed up cheat */
  36.     if (speedcheat)
  37.     {
  38.         if (readinputport(4) & 1)    /* check status of the fake dip switch */
  39.         {
  40.             /* activate the cheat */
  41.             RAM[0x180b] = 0x01;
  42.             RAM[0x1ffd] = 0xbd;
  43.         }
  44.         else
  45.         {
  46.             /* remove the cheat */
  47.             RAM[0x180b] = 0xbe;
  48.             RAM[0x1ffd] = 0x00;
  49.         }
  50.     }
  51.  
  52.     return interrupt();
  53. }
  54.